<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .menu {
      width: 300px;
      display: flex;
      background-color: darkgray;
    }

    h4 {
      width: 100px;
      cursor: pointer;
    }

    .active {
      background-color: dodgerblue;
      color: floralwhite;
    }

    .content {
      width: 500px;
      height: 250px;
      background-color: grey;
    }

    .content>article {
      width: 100%;
      height: 100%;
    }
  </style>
</head>

<body>
  <div id="app">
    <div class="menu">
      <h4 v-for="(item, index) in tabs" @click="switchTab(index)" :class="{active: num === index}">{{item.title}}</h4>
    </div>
    <div class="content">
      <article v-for="(item, index) in tabs" v-show="num === index">{{item.content}}</article>
    </div>  
  </div>
  <script src="../vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        num: 0,
        tabs: [
          {
            title:'标题1',
            content: '内容1'
          },
          {
            title:'标题2',
            content: '内容2'
          },
          {
            title:'标题3',
            content: '内容3'
          },
          {
            title:'标题4',
            content: '内容4'
          }
        ]
      },
      methods: {
        switchTab(n) {
          this.num = n
        }
      }
    })
  </script>
</body>

</html>